package com.baicaixiaozhan.springsecurityswaggerdemo.pojo;

import java.util.Objects;

/**
 * DESC:
 *
 * @author : baicaixiaozhan
 * @since : 2020-11-04
 */
public class Person {
    private String name;
    private String address;

    public Person() {}
    public Person(String name, String address) {
        this.name = name;
        this.address = address;
    }
    public Person(PersonBuilder personBuilder) {
        this.name = personBuilder.name;
        this.address = personBuilder.address;
    }

    public static PersonBuilder builder() {
        return new PersonBuilder();
    }

    public static class PersonBuilder {
        private String name;
        private String address;
        private PersonBuilder() {
        }
        public PersonBuilder name(String name) {
            this.name = name;
            return this;
        }
        public PersonBuilder address(String address) {
            this.address = address;
            return this;
        }

        public Person build() {
            return new Person(this);
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }
            PersonBuilder that = (PersonBuilder) o;
            return Objects.equals(name, that.name) &&
                    Objects.equals(address, that.address);
        }

        @Override
        public int hashCode() {
            return Objects.hash(name, address);
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", address='" + address + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Person person = (Person) o;
        return Objects.equals(name, person.name) &&
                Objects.equals(address, person.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, address);
    }
}
